<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
	<html>

	<head>
		<meta charset="utf-8">
		<title>定向解答</title>
		<link href="css/myui.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" href="css/myui.css">
		<style type="text/css">
			html,body{
				/*background: #f5f5f5;*/
			}
			.reservation_content{
				position: absolute;
			    z-index: 2;
			    top: 0;
			    bottom: 2.6rem;
			    left: 0;
			    overflow: hidden;
			    width: 100%;
			    margin-top: 3rem;
			}
			.reservation_content1:nth-child(1){
				margin-top: 0 !important;
			}
			.reservation_content1:nth-child(2){
				margin-top: 0.1rem !important;
				border-top: 0.1rem solid #f5f5f5;
			}
			.reservation_content1_content{
				background: #fffaec;
			}
			.reservation_content1_content>p{
				color: #464646;
				font-size: 0.8rem;
				margin-bottom: 0px;
			}
			.reservation_content1>a{
				display: block;
			    position: relative;
			    text-align: center;
			    font-size: 1rem;
			    right: 0;
			    background: #fff;
			    color: #464646;
			    margin-top: 1rem;
			    padding-bottom: 0;
			}
			.plaza_details_footer{
				background: #53b0ff;
				color: #fff;
				display: block;
			    height: 2.6rem;
			    line-height: 1.6rem;
			    text-align: center;
			    padding: 0.5rem 0;
			    position: fixed;
			    font-size: 1rem;
			    bottom: 0;
			    z-index: 9;
			    width: 100%;
			}
			#textarea{
				margin: 0;
				padding: 2%;
				font-size: 0.8rem;
				margin-top: 1rem;
			}
		</style>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/jquery-1.9.0.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>

	<body>

		<div id="app" class="mui-views" data-view="1">
			<div class="mui-view">
				<div class="mui-navbar">
					<div class="mui-navbar-inner mui-bar mui-bar-nav mui-navbar-center">
						<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left mui-pull-left_style">
							<span class="mui-icon mui-icon-left-nav"></span>
						</button>
						<h1 class="mui-center mui-title mui-title_fff" style="margin-left: -15px;">定向解答</h1>
					</div>
				</div>
				<div class="mui-pages">
					<div id="setting" class="mui-page mui-page-center">
			<!--页面主内容区结束-->
					</div>
				</div>
			</div>
		</div>

		<div class="reservation_content">
			<div class="mui-scroll">
			</div>
		</div>

		<div class="mui-pull-bottom-pocket mui-block mui-visibility"><div class="mui-pull" id="loding_is"><div class="mui-pull-loading mui-icon mui-spinner mui-visibility"></div><div class="mui-pull-caption mui-pull-caption-refresh">正在加载...</div></div></div>
		
		<a href="javascript:;" class="plaza_details_footer" id="answer_details">确&nbsp;&nbsp;认</a>
				
		
	</body>

	<script src="js/index.js"></script>
	<script src="js/jquery-1.9.0.js"></script>
	<script type="text/javascript">
		mui('.reservation_content').scroll();
		
		$(".mui-scrollbar").css("display","none");
		
		var GetRequest = function(url){//获取url，获取id的方法
			  var url = location.search; //获取url中"?"符后的字串
			  var theRequest = new Object();
			 	if (url.indexOf("?") != -1) {
			        var str = url.substr(1);
			        strs = str.split("&");
			        for(var i = 0; i < strs.length; i ++) {
			           theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
			        }
				}
			 return theRequest;
		}

			var count = 0;
			var phoneNum = "";
			var lawyerID = "";
			var url=location.href;
			var obj=GetRequest(url);
			var questionId=obj.id;
			mui.plusReady(function(){
				phoneNum = localStorage.getItem("phoneNum");
				lawyerID = localStorage.getItem("lawyerID");
				var reply = localStorage.getItem("reply");
				var whoQue = "";
				/**
				 * 上拉加载具体业务实现
				 */
				//alert(reply);
				var table = document.body.querySelector('.mui-table-view');
				var count_length = 10;
				var count_json;
				var url_post = get_url() + 'questionAnswer/qDetail/'+questionId;
				$.ajax({
					url: url_post,
				    dataType: 'JSONP',//加入这个选项即可
					data: {},
				    jsonp: "jsonpcallback",
				    beforeSend: function (xhr) {
				    },
					success: function(json){
						$("#loding_is").hide();
						var html_1 = "";
						var html1 = "";
						count++;
						if(json == null	|| json == ""){
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
							$(".mui-pull-bottom-pocket").css("visibility","inherit");
							return count;
						}
						whoQue = json[0].CREATEUSER;
						var li = "";
						var imgPath = json[0].imgPath = ""?json[0].imgPath:'img/touxiang.png';
						var userName = json[0].CREATEUSER.substr(0,3)+'*******'+json[0].CREATEUSER.substr(9,11);
						li += '<div class="reservation_content1 answer_titleNo">'+
									'<div class="reservation_content1_title">'+
										'<div class="reservation_content1_title_left">'+
											'<img src="'+ imgPath +'">'+
										'</div>'+
										'<div class="reservation_content1_title_right">'+
											'<p>'+ userName +'</p>'+
											'<p>'+ json[0].CREATETIME +'</p>'+
										'</div>'+
									'</div>'+
									'<div class="reservation_content1_content" style="background: #ecf6ff;">'+
										'<p>'+ json[0].CONTENT +'</p>'+
									'</div>'+
								'</div>'+
								'<div class="reservation_content1">'+
									'<textarea id="textarea" rows="5" placeholder="可提供有效证据..."></textarea>'+
								'</div>';
						$(".mui-scroll").html(li);
					},
					error: function(jqXHR, textStatus, errorThrown) {
						mui.plusReady(function(){
								document.addEventListener("netchange", wainshow, false);
								wainshow();
							//message();
							});
							function wainshow() {
								if (plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
								mui.toast("网络异常，请检查网络设置！");				
								} else {
								//mui.toast("网络正常");
								}
							}
					}
				});
				
				document.getElementById('answer_details').addEventListener('tap', function() {
					var url_details = "";
					if(reply == 1){
						url_details += get_url() + 'questionAnswer/evaluate/'+ phoneNum +'/'+lawyerID;
						get_hrefURL(url_details);
					}else{
						url_details += get_url() + 'questionAnswer/answer';
						get_hrefURL(url_details);
					}
				});
				
				function get_hrefURL(IDurl){
						var textarea = $("#textarea").val();
						if(textarea != "" && textarea != null){
							$.ajax({
								url: IDurl,
							    dataType: 'JSONP',//加入这个选项即可
								data: {
									"content":textarea,
									"anwserwho": phoneNum,
									"questionid":questionId,
									"whoque":whoQue
								},
							    jsonp: "jsonpcallback",
							    beforeSend: function (xhr) {
							    },
								success: function(json){
									if (json == true && textarea != "" && textarea != null) {
										mui.toast("发布成功！！");
										mui.openWindow({
										    url: 'answer_details.html?id='+questionId, 
										    id:'answer_details',
										    waiting: {  
										        autoShow: true, //自动显示等待框，默认为true  
										        title: '正在加载...', //等待对话框上显示的提示内容  
										    } 
										  });
									} else {
										mui.toast("发布失败");
									}
								},
								error: function(jqXHR, textStatus, errorThrown) {
									mui.plusReady(function(){
											document.addEventListener("netchange", wainshow, false);
											wainshow();
										//message();
										});
										function wainshow() {
											if (plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
											mui.toast("网络异常，请检查网络设置！");				
											} else {
											//mui.toast("网络正常");
											}
										}
								}
							});
						}else {
							mui.toast("回复不能为空");
						}
					}
			});
				
		var view = viewApi.view;
		(function($) {
			//处理view的后退与webview后退
			var oldBack = $.back;
			$.back = function() {
				if (viewApi.canBack()) { //如果view可以后退，则执行view的后退
					viewApi.back();
				} else { //执行webview后退
					oldBack();
				}
			};
			//监听页面切换事件方案1,通过view元素监听所有页面切换事件，目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发)
			//第一个参数为事件名称，第二个参数为事件回调，其中e.detail.page为当前页面的html对象
			view.addEventListener('pageBeforeShow', function(e) {
				//				console.log(e.detail.page.id + ' beforeShow');
			});
			view.addEventListener('pageShow', function(e) {
				//				console.log(e.detail.page.id + ' show');
			});
			view.addEventListener('pageBeforeBack', function(e) {
				//				console.log(e.detail.page.id + ' beforeBack');
			});
			view.addEventListener('pageBack', function(e) {
				//				console.log(e.detail.page.id + ' back');
			});
		})(mui);
	</script>
	</html>